package com.iweb.day12;

/**
 * @author WuYongheng
 * @date 2021/12/5
 * @description 体验共享资源
 */
public class MyRunnable2 implements Runnable {
    int num = 1000;

    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            this.num--;
        }
    }

    public static void main(String[] args) {
        MyRunnable2 r2=new MyRunnable2();
        for (int i = 0; i < 10; i++) {
            Thread t=new Thread(r2);
            t.start();
        }
        System.out.println(r2.num);
        System.out.println(r2.num);
        System.out.println(r2.num);
    }
}

